
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantInfoSearchRequest;
import com.insigma.business.qrcode.merchant.dto.search.CareWelfareMerchantInfoBSearcher;
import com.insigma.business.qrcode.welfare.dto.CareWelfareMerchantInfoDTO;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantInfoInsertRequest;
import com.insigma.business.qrcode.merchant.dto.request.CareWelfareMerchantInfoUpdateRequest;
import com.insigma.business.qrcode.merchant.entity.CareWelfareMerchantInfoDO;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CareWelfareMerchantInfoProviderConverter extends AbstractConverter<CareWelfareMerchantInfoDTO, CareWelfareMerchantInfoDO> {

    private final static CareWelfareMerchantInfoProviderConverter careWelfareMerchantInfoConverter = new CareWelfareMerchantInfoProviderConverter();

    private CareWelfareMerchantInfoProviderConverter(){}

    
    public static CareWelfareMerchantInfoBSearcher convertRequestSO2Searcher(final CareWelfareMerchantInfoSearchRequest request){
        final CareWelfareMerchantInfoBSearcher careWelfareMerchantInfoBSearcher = new CareWelfareMerchantInfoBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,careWelfareMerchantInfoBSearcher);
        return careWelfareMerchantInfoBSearcher;
    }

    
    public static CareWelfareMerchantInfoDO convertRequestUO2DO(final CareWelfareMerchantInfoUpdateRequest careWelfareMerchantInfoUpdateRequest) {
        final CareWelfareMerchantInfoDO careWelfareMerchantInfoDO = new CareWelfareMerchantInfoDO();
        BeanUtils.copyProperties(careWelfareMerchantInfoUpdateRequest,careWelfareMerchantInfoDO);
        
        return careWelfareMerchantInfoDO;
    }

    
    public static CareWelfareMerchantInfoDO convertRequestIO2DO(final CareWelfareMerchantInfoInsertRequest careWelfareMerchantInfoInsertRequest) {
        final CareWelfareMerchantInfoDO careWelfareMerchantInfoDO = new CareWelfareMerchantInfoDO();
        BeanUtils.copyProperties(careWelfareMerchantInfoInsertRequest,careWelfareMerchantInfoDO);
        return careWelfareMerchantInfoDO;
    }

    
    public static List<CareWelfareMerchantInfoDTO> convertResponseDOList2DTOList(final List<CareWelfareMerchantInfoDO> careWelfareMerchantInfoDOList){
        return careWelfareMerchantInfoConverter.convertGenericResponseDOList2DTOList(careWelfareMerchantInfoDOList);
    }

    
    public static CareWelfareMerchantInfoDTO convertResponseDO2DTO(final CareWelfareMerchantInfoDO careWelfareMerchantInfoDO){
        return careWelfareMerchantInfoConverter.convertGenericResponseDO2DTO(careWelfareMerchantInfoDO);
    }

    
    @Override
    protected CareWelfareMerchantInfoDTO doConvertResponseDO2DTO(CareWelfareMerchantInfoDO careWelfareMerchantInfoDO) {
        final CareWelfareMerchantInfoDTO careWelfareMerchantInfoDTO = new CareWelfareMerchantInfoDTO();
        try {
            BeanUtils.copyProperties(careWelfareMerchantInfoDO, careWelfareMerchantInfoDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return careWelfareMerchantInfoDTO;
    }

}
